#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct TreeNode {
	int val;
	struct TreeNode *left;
	struct TreeNode *right;
};

int* decorateRecord(struct TreeNode* root, int* returnSize) {
	if(root == NULL){
		*returnSize = 0;
		return NULL;
	}
	struct TreeNode **tree = (struct TreeNode**)malloc(1024 * sizeof(struct TreeNode*));
	memset(tree, 0, 1024 * sizeof(struct TreeNode*));
	int read = 0, length = 0;
	tree[length++] = root;
	while(read < length){
		if(tree[read]->left != NULL){
			tree[length++] = tree[read]->left;
		}
		if(tree[read]->right != NULL){
			tree[length++] = tree[read]->right;
		}
		read++;
	}
	int *outTree = (int*)malloc(length * sizeof(int));
	for(int i = 0; i < length; i++){
		outTree[i] = tree[i]->val;
	}
	*returnSize = length;
	return outTree;
}

